// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space
// Source File Name:   CamelCaseToMapResultTransformer.java

package com.sailing.xjpb.orm.utils;

import com.google.common.base.CaseFormat;
import org.hibernate.transform.AliasedTupleSubsetResultTransformer;

import java.util.HashMap;
import java.util.Map;


public class CamelCaseToMapResultTransformer extends AliasedTupleSubsetResultTransformer {

    private static final long serialVersionUID = 1L;
    public static final CamelCaseToMapResultTransformer INSTANCE = new CamelCaseToMapResultTransformer();

    private CamelCaseToMapResultTransformer() {

    }

    @Override
    public Object transformTuple(Object[] tuple, String[] aliases) {
        Map<String, Object> result = new HashMap<>(tuple.length);
        for (int i = 0; i < tuple.length; i++) {
            String alias = aliases[i];
            if (alias != null) {
                alias = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, alias);
                result.put(alias, tuple[i]);
            }
        }

        return result;
    }

    @Override
    public boolean isTransformedValueATupleElement(String[] aliases, int tupleLength) {
        return false;
    }

}
